<template>
  <svg :class="svgClass" aria-hidden="true" @click="handleClick">
    <use :xlink:href="iconHref" />
  </svg>
</template>

<script>
export default {
  name: 'Icon',
  props: {
    iconName: {
      type: String,
      default: '',
      require: true
    },
    className: {
      type: String,
      default: ''
    }
  },
  computed: {
    iconHref() {
      return `#${this.iconName}`
    },
    svgClass() {
      if (this.className) {
        return 'icon ' + this.className
      } else {
        return 'icon'
      }
    }
  },
  methods: {
    handleClick() {
      // this.$emit('click')
    }
  }
}
</script>

<style scoped>
.icon {
  width: 1em;
  height: 1em;
  vertical-align: middle;
  fill: currentColor;
  overflow: hidden;
}
</style>
